package top.tsyz.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.tsyz.entity.ProductReview;
import top.tsyz.service.IProductReviewService;

import java.util.List;

/**
 * ProductReviewController控制器
 */
@RestController
@RequestMapping("/api/productReviews")
@Api(tags = "ProductReview管理接口")
public class ProductReviewController {

    @Autowired
    private IProductReviewService iproductreviewservice;

    @GetMapping("/list")
    @ApiOperation("获取所有ProductReview")
    public List<ProductReview> list() {
        return iproductreviewservice.list();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据ID获取ProductReview")
    public ProductReview getById(@PathVariable Long id) {
        return iproductreviewservice.getById(id);
    }

    @PostMapping
    @ApiOperation("新增ProductReview")
    public boolean save(@RequestBody ProductReview productreview) {
        return iproductreviewservice.save(productreview);
    }

    @PutMapping
    @ApiOperation("更新ProductReview")
    public boolean update(@RequestBody ProductReview productreview) {
        return iproductreviewservice.updateById(productreview);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除ProductReview")
    public boolean delete(@PathVariable Long id) {
        return iproductreviewservice.removeById(id);
    }
}
